package com.xjg.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component;

import com.xjg.domain.LoginPushRecord;

@Component
public class LoginPushRecordDao {
	@Autowired
	private MongoTemplate mongoTemplate;
	
	public void save(LoginPushRecord lpr){
		mongoTemplate.save(lpr);
	}
	/**
	 * 根据用户id查询push登录记录
	 * @param userid
	 * @return
	 */
	public LoginPushRecord getRecordByUserid(String userid){
		Query query = new Query(Criteria.where("userid").is(userid));
		
		return mongoTemplate.findOne(query, LoginPushRecord.class);
	}
	
	public void removeByUserid(String userid){
		Query query = new Query(Criteria.where("userid").is(userid));
		mongoTemplate.remove(query, LoginPushRecord.class);
	}
	
}
